package com.gg.fruit.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.gg.entity.Fruit;
import com.gg.fruit.service.FruitService;

import base.BaseServlet;


@WebServlet("/fruit/GetFruitsByCategoryServlet")
public class GetFruitsByCategoryServlet extends BaseServlet {
	@Autowired
	private  FruitService  fruitService;
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String cid =  request.getParameter("cid");
		Fruit  fruit =  new Fruit();
		fruit.setCid(cid);
		
		List<Fruit>  fruits = fruitService.getFruitsBySearch(fruit);
		request.getSession().setAttribute("fruits", fruits);
		
		response.sendRedirect("/fruits/sel.jsp");
		
		
		
	}

	
}
